package main

import (
	"crypto/tls"
	"crypto/x509"
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"os"
)

func main() {

	caPath := "./ca.crt"
	pemDate, _ := ioutil.ReadFile(caPath)

	rootca := x509.NewCertPool()
	rootca.AppendCertsFromPEM(pemDate)

	tlsConfig := &tls.Config{
		RootCAs: rootca,
	}

	tr := &http.Transport{
		TLSClientConfig: tlsConfig,
	}
	client := &http.Client{
		Transport: tr,
	}

	resp, err := client.Get(("https://localhost:1881/"))
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	io.Copy(os.Stdout, resp.Body)

	fmt.Println("end")

}
